﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.IO;
using System.Threading;


namespace ATM
{
    public partial class currencyFromPound : Form
    {
        AccountLogic accoun = new AccountLogic();
        CurrencyTranLogic lo = new CurrencyTranLogic();
       public string accuN, mony , CList;
        public currencyFromPound(string acc)
        {
            InitializeComponent();
            accuN = acc;
        }

        void display_show()
        {

            int height = 249;
            while (height <= 329)
            {
                this.Size = new Size(520, height);
                this.Refresh();
                this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
                this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
                this.SetStyle(ControlStyles.UserPaint, true);
                Thread.Sleep(10);
                height += 10;
            }
        }

        private void form_Load(object sender, EventArgs e)
        {
            this.Size = new Size(520, 249);
        }

        private void calculateButt_Click(object sender, System.EventArgs e)
        {
            mony = currencycount.Text;
            CList = currencyList.Text;

            lo.calculate_from_call(CList, mony);

            if (lo.checkEmtpy == 0)
                MessageBox.Show("Please select currency type and number of pounds to calculate");
            else
            {
                if (lo.checkWrong == 1)
                {
                    show_pounds.Text = lo.calculate.ToString();
                    display_show();
                }
                else
                {
                    MessageBox.Show("Please Enter a valid numbers !");
                    currencycount.Text = "";
                }
            }

        }

        private void exitButt_Click(object sender, EventArgs e)
        {
            welcom w = new welcom();
            w.Show();
            this.Hide();
        }

        private void numbers_buttons(object sender, EventArgs e)
        {
            Button b = (Button)sender;
            currencycount.Text = currencycount.Text + b.Text;
        }

        private void backButt_Click(object sender, EventArgs e)
        {
            CurrencyTransIntro inter = new CurrencyTransIntro(accuN);
            inter.Show();
            this.Hide();
        }

        private void bcash_Click(object sender, EventArgs e)
        {
            inter_face inter = new inter_face(accuN);
            inter.Show();
            this.Hide();
            MessageBox.Show("Your mony is coming out shortly");
        }

        private void b_balance_Click(object sender, EventArgs e)
        {

            lo.take_f_balnce(accuN ,mony);
            if (lo.checkmony == 1)
            {
                inter_face inter = new inter_face(accuN);
                inter.Show();
                this.Hide();
            }
            else
                MessageBox.Show("Not enough balance !");
        }

        private void clear_Click(object sender, EventArgs e)
        {
            currencycount.Text = "";
        }
    }
}
